package cn.newgrand.netcall.base;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;

import javax.swing.Icon;
import javax.swing.JLabel;
import javax.swing.JPanel;

import org.jivesoftware.resource.SparkRes;

import cn.newgrand.netcall.personal.contact.entity.PersonalGroup;

public class RoomItem extends JPanel{
	private JLabel imageLabel;
    private JLabel displayNameLabel;
    private JLabel descriptionLabel;
    private String roomName;
    private String alias;
    private String roomJID;
    private Icon icon;
    
    public RoomItem(String roomName,String roomJID){
    	setLayout(new GridBagLayout());
    	displayNameLabel = new JLabel();
        descriptionLabel = new JLabel();
        imageLabel = new JLabel();
        imageLabel.setIcon(SparkRes.getImageIcon(SparkRes.BOOKMARK_ICON));
        
        displayNameLabel = new JLabel(roomName);
        this.roomName = roomName;
        this.roomJID = roomJID;
        
        add(imageLabel, new GridBagConstraints(0, 0, 0, 0, 0.0, 0.0, GridBagConstraints.SOUTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 15, 3, 0), 0, 0));
        add(displayNameLabel, new GridBagConstraints(1, 0, 0, 0, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 35, 0, 0), 0, 0));
        
//        add(imageLabel, new GridBagConstraints(0, 0, 0, 0, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 15, 3, 0), 0, 0));
//        add(displayNameLabel, new GridBagConstraints(1, 0, 0, 0, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 0), 0, 0));
        
        
    }
    public String getRoomJID(){
    	return roomJID;
    }
    public void setRoomJID(String roomJID){
    	this.roomJID = roomJID;
    }
    public void setIcon(Icon icon){
    	this.icon = icon;
    	imageLabel.setIcon(icon);
    }
   
//    @Override
//    public boolean equals(Object obj) {
//    	if(this == obj) return true;
//		if(null==obj||!getClass().isInstance(obj)) return false;
//		
//		final RoomItem ri = (RoomItem) obj;
//
//		if (roomJID != null ? !roomJID.equals(ri.roomJID) : ri.roomJID != null) {
//			return false;
//		}
//		return true;
//    }
//    
//    @Override
//    public int hashCode() {
//    	return roomJID.hashCode();
//    }
    
}
